﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace onPulse01
{
    public partial class Profiles : PhoneApplicationPage
    {
        private AppSettings settings = new AppSettings();
        string profileId = "";
        
        public Profiles()
        {
            InitializeComponent();

            profileId = settings.ProfileId;
            
            getData();
        }        

        private void getData()
        {
            GoogleConnect gc = new GoogleConnect();
            gc.GetProfiles();
            gc.getEvent += new GoogleGetHandler(listing);           
        }

        private void listing(object sender, GoogleGetEventArgs e)
        {
            GoogleData gd = new GoogleData();
            ProfilesList.DataContext = gd.getProfilesList(e.Data);

            ///TODO: ustawić aktulany profil (IsChecked)
        }

        private void doneButton_Click(object sender, EventArgs e)
        {
            settings.ProfileId = profileId;
            NavigationService.GoBack();
        }

        private void cancelButton_Click(object sender, EventArgs e)
        {
            NavigationService.GoBack();
        }

        private void RadioButton_Checked(object sender, RoutedEventArgs e)
        {
            profileId = ((RadioButton)sender).Name;
        }

    }
}